package ioperation;

import book.BookList;

import java.util.Scanner;

public class DelBook implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("输入你要删除的图书: ");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getUsedSize()-1; i++) {
            if(bookList.books[i].getName().equals(name)) {
                for (int j = i; j < bookList.getUsedSize()-1; j++) {
                    bookList.books[j] = bookList.books[j+1];
            }
            }
        }
        System.out.println("删除成功");
        bookList.setUsedSize(bookList.getUsedSize()-1);
    }
}
